package com.drug.mingkang.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 描述：虚拟路径配置
 *
 * @version 1.0
 * @author: wcj
 * @Date: 2020/7/25 17:21
 */
@Configuration
@PropertySource("classpath:config/conf.properties")
public class FileConfig implements WebMvcConfigurer {

    @Value("${file.saveFilePath}")
    public  String saveFilePath;
    @Value("${file.staticAccessPath}")
    public String staticAccessPath;

    /**
     * 虚拟路径配置
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(staticAccessPath).addResourceLocations(saveFilePath);
        WebMvcConfigurer.super.addResourceHandlers(registry);
    }
}
